from django.shortcuts import render
from django.http import HttpResponse


# Create your views here.


def set_cookie(request):
    response = HttpResponse('set_cookie')
    response.set_cookie('name', 'sam')
    return response


def get_cookie(request):
    print(request.COOKIES)
    return HttpResponse('get_cookie')


def set_session(request):
    request.session['name'] = 'lining'
    request.session['age'] = '23'
    return HttpResponse('set_session')


def get_session(request):
    name = request.session.get('name')
    age = request.session.get('age')
    print(name, age)
    return HttpResponse('get_seesion')


# 删除session
def pop_session(requset):
    requset.session.pop('name')
    return HttpResponse('pop_session')




def clear_session(request):
    request.session.clear()
    return HttpResponse('clear_session')



def flush_session(request):
    request.session.flush()
    return HttpResponse('flush_session')

